#include "inputmanager.h"
#include "commanddispatcher.h"
#include "command.h"

namespace ShCo
{

class InputManagerImpl : public Impl<InputManager>
{
public:
    void init();
    void exit();
    CommandDispatcher* _dispatcher;
};

void InputManagerImpl::init()
{
    _dispatcher = new CommandDispatcher();
}

void InputManagerImpl::exit()
{
    SH_SAFE_DELETE(_dispatcher);
}

InputManager::InputManager()
{
    SH_I(InputManager);
    d->init();
}

InputManager::~InputManager()
{
    SH_E(InputManager);
    d->exit();
}

void InputManager::event(const SsUiEvent* evt)
{
    SH_D(InputManager);
    Command* cmd = d->_dispatcher->command();
    if (cmd)
        cmd->event(evt);
}

} // namespace ShCo
